package com.itheima.config;


import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

//TODO:配置SqlSessionFactory和MapperScannerConfigurer
public class MybatisConfig {
    @Bean
    public SqlSessionFactoryBean getSqlSessionFactoryBean(DataSource ds){
        SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
           factoryBean.setTypeAliasesPackage("com.itheima.domain");
           factoryBean.setDataSource(ds);
           return factoryBean;
    }
   @Bean
    public MapperScannerConfigurer mapperScannerConfigurer(){
        MapperScannerConfigurer masc=new MapperScannerConfigurer();
        masc.setBasePackage("com.itheima.mapper");
        return  masc;
    }


}
